/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.oa.web;

import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.thinkgem.jeesite.common.web.BaseController;

import com.thinkgem.jeesite.modules.oa.dao.OaCarQryDao;
import com.thinkgem.jeesite.modules.oa.entity.OaCarQryVo;
import com.thinkgem.jeesite.modules.oa.service.OaCarQryService;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 派车单查询
 *
 * @author ThinkGem
 * @version 2014-05-16
 */
@Controller
@RequestMapping(value = "${adminPath}/oa/carQry")
public class OaCarQryController extends BaseController {

    @Autowired
    private OaCarQryService oaCarQryService;

    @ModelAttribute
    public OaCarQryVo get(@RequestParam(required = false) String id) {
        OaCarQryVo entity = null;
        if (StringUtils.isNotBlank(id)) {
            entity = oaCarQryService.get(id);
        }
        if (entity == null) {
            entity = new OaCarQryVo();
        }
        return entity;
    }

    @RequiresPermissions("oa:carQry:view")
    @RequestMapping(value = {"list", ""})
    public String list(OaCarQryVo oaCarQryVo, HttpServletRequest request, HttpServletResponse response, Model model) {
        Page<OaCarQryVo> page = oaCarQryService.find(new Page<OaCarQryVo>(request, response), oaCarQryVo);
        model.addAttribute("page", page);
        return "modules/oa/oaCarQryList";
    }

}